package com.sskj.ffex.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.ffex.MyAppLication;
import com.sskj.ffex.common.Constants;
import com.sskj.ffex.m.HttpConfig;
import com.sskj.ffex.m.bean.HttpData;
import com.sskj.ffex.m.bean.UserInfo;
import com.sskj.ffex.m.http.JsonCallBack;
import com.sskj.ffex.p.base.BasePresenter;
import com.sskj.ffex.utils.SPUtils;
import com.sskj.ffex.utils.ToastUtil;
import com.sskj.ffex.v.activity.SellerApplyActivity;


public class SellerApplyPresenter extends BasePresenter<SellerApplyActivity> {

    public void apply() {
        OkGo.<HttpData>post(HttpConfig.BASE_URL+HttpConfig.APPLY_SELLER)

                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData> response) {
                        if (response.body().getStatus() == 200) {
                            mView.startFabiPublish();
                        }else {
                            ToastUtil.getInstance(mContext).showMessage(response.body().getMsg());
                        }
                    }
                });
    }
    public void requestUserInfo( ) {
        OkGo.<HttpData<UserInfo>>post(HttpConfig.BASE_URL + HttpConfig.GET_USER_INFO)
                .params("mobile", MyAppLication.getMobile())
                .execute(new JsonCallBack<HttpData<UserInfo>>(this, true) {
                    @Override
                    public void _onSuccess(Response<HttpData<UserInfo>> response) {
                        HttpData<UserInfo> httpData = response.body();
                        if (httpData.getStatus() == 200) {
                            SPUtils.put(MyAppLication.getApplication(), Constants.SP_IS_SHOP, httpData.getData().is_shop);
                            mView.updateUser(httpData.getData());
                        }
                    }

                });
    }
}
